<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>扫码加入城市群</title>
	{$h->import('static/css/layui.css')}
	{$h->import('static/css/HyqPublic.css')}
	{$h->import('static/css/StoreCode.css')}
	{$h->import('static/layui/css/modules/code.css')}
	{$h->import('static/layui/css/modules/laydate/default/laydate.css')}
	{$h->import('static/layui/css/modules/layer/default/layer.css')}
</head>
<style type="text/css">
  /*------------分页部分--------------*/
    .pageing-container-h{
      display: flex;
      justify-content: space-between;
      padding: 0px 20px 20px 20px;
    }
    .pageing-content-h{
      line-height: 28px;
    }
    .pageing-content-h a{
      border: 1px solid #e2e2e2;
      padding: 4px 15px;
      color: #333;
      line-height: 28px;
      border-radius: 2px;
    }
   .current{
     background: #1E9FFF !important;
     color: #fff !important;
   }
</style>
<body>
	<!-- 顶部导航 start -->
	<div class="StoreCode_headerNav_container">
		<ul class="StoreCode_headerNav_content">
			<li>
				<a href="/Addons/StoresCode/admin/StoresCode/index.html" >扫码添加店主</a>
			</li>
			<li>
				<a href="/Addons/StoresCode/admin/GroupCode/index.html">扫码加入门店群</a>
			</li>
			<li>
				<a href="index.html" class="StoreCode_headerNavActive">扫码加入城市群</a>
			</li>
		</ul>
	</div>
	<!-- 顶部导航 end -->
	<!-- 主要内容区 -->
	<div class="StoreCode_main_container">
		<!-- 主要内容区切换tabs -->
		<ul class="StoreCode_mainNav_container">
			<a href="index.html"><li class="StoreCode_mainNavActive" data-type="store">门店列表</li></a>
			<a href="city_data_stores-1.html"><li data-type="data">数据分析</li></a>
		</ul>
		<!-- 切换区门店列表页面 -->
		<div class="StoreCode_TabsStoreList_container">
			<div class="StoreCode_TabsStoreList_From_container layui-form">
				<div class="public_form_conainer public_select_container">
					<span class="public_formTitle">城市：</span>
					<div class="public_select_content ">
						<select id="city" lay-verify="required" lay-filter="lay-search">
							<option value=""></option>
							{loop $citys as $city}
								<option value="{$city}" {if $city_one == $city} selected {/if}>{$city}</option>
							{/loop}
						</select>
					</div>
				</div>
				<div class="public_form_conainer public_search_container">
					<span class="public_formTitle">拉群活码：</span>
					<div class="public_search_content">
						<input type="text" placeholder="请输入拉群活码" id="name" value="{$name}">
						<svg t="1622189504456" class="icon" onclick="search()" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2625" width="17" height="17"><path d="M426.666311 853.332622a426.666311 426.666311 0 1 1 426.666311-426.666311 426.666311 426.666311 0 0 1-426.666311 426.666311z m0-767.99936a341.333049 341.333049 0 1 0 341.333049 341.333049 341.333049 341.333049 0 0 0-341.333049-341.333049z" p-id="2626" fill="#8c8c8c"></path><path d="M981.332516 1023.999147a42.666631 42.666631 0 0 1-30.293309-12.373323L682.666098 743.252714A42.666631 42.666631 0 0 1 743.252714 682.666098l268.37311 267.946443a42.666631 42.666631 0 0 1 0 60.586616 42.666631 42.666631 0 0 1-30.293308 12.79999z" p-id="2627" fill="#8c8c8c"></path></svg>
					</div>
				</div>
				<div class="public_form_conainer public_select_container" style="margin-right: 90px;">
					<span class="public_formTitle">开启状态：</span>
					<div class="public_select_content">
						<select id="status" lay-verify="required" lay-filter="lay-search">
							<option value=""></option>
							<option value="1" {if $status == 1} selected {/if}>已开启</option>
							<option value="2" {if $status == 2} selected {/if}>未开启</option>
						</select>
					</div>
				</div>
				<button class="layui-btn layui-btn-primary StoreCode_TabsStoreList_From_button public_button" onclick="reset()">重置</button>
			</div>
			<!-- table 上的按钮区域 -->
			<div class="StoreCode_TabsStoreList_tableHeader_container">
				<h3>共1个城市</h3>
				<ul class="StoreCode_TabsStoreList_tableHeaderButton_container">
					<li>
						<button type="button" class="layui-btn layui-btn-primary public-button-border-blue public_button" id="Add-Store">添加城市</button>
						<div class="StoreCode_AddStroeHide_container" style="display: none;">
							<div class="StoreCode_AddStroeHide_content addstore">
								<span>新建城市</span>
							</div>
							<div class="StoreCode_AddStroeHide_content" id="importstore">
								<span>导入城市</span>
							</div>
						</div>
					</li>
					<li>
						<button type="button" class="layui-btn layui-btn-primary public-button-border-blue public_button" id="setting">设置</button>
					</li>
					<li>
						<button type="button" class="layui-btn layui-btn-primary public-button-border-blue public_button" id="share">分享</button>
					</li>
				</ul>
			</div>
			<!-- table 区域 -->
			<div class="StoreCode_TabsStoreList_table_container">
				<table class="layui-table layui-form" lay-skin="line">
					<colgroup>
						<col>
						<col>
						<col>
						<col>
					</colgroup>
					<thead>
						<tr style="background: #fcfcfc;">
							<th>城市</th>
							<th>拉群活码<i class="layui-icon layui-icon-help" id="sones" style="font-size: 8px;cursor: pointer;" onmouseout="mous()" onmouseover="check()" ></i></th>
							<th>状态<i class="layui-icon layui-icon-help" id="sone" style="font-size: 8px;cursor: pointer;" onmouseout="mous()" onmouseover="checks()" ></i></th>
							<th>操作</th>
						</tr> 
					</thead>
					<tbody>
						{loop $data as $datas}
						<tr>
							<td>{$datas["stores_city"]}</td>
							<td>
								<div class="public_form_conainer public_select_container" style="margin: 0 !important;">
									<div class="public_select_content">
										<select name="city" lay-verify="required" lay-filter="upd_way" data="{$datas['id']}">
											<option></option>
											{loop $contactWay as $way}
												<option value="{$way['id']}" {if $way['id'] == $datas['contact_id']} selected {/if}>{$way["name"]}</option>
											{/loop}
										</select>
									</div>
								</div>
							</td>
							<td>
								<input type="checkbox" name="close" lay-skin="switch" lay-filter="switchTest" value="{$datas['id']}" {if $datas["status"]==1} checked {/if}>
							</td>
							<td class="table-btn-container">
								<span onclick="add_city({$datas['id']})">修改</span>
								<span onclick="del_city({$datas['id']})">删除</span>
							</td>
						</tr>
						{/loop}
					</tbody>
				</table>
			</div>
		</div>
		<div class="main-container-h pageing-container-h">
        <div class="pageing-content-h">
            <span>{$p->totalnum}条/{$p->totalpage}页</span>
        </div>
      	<ul class="pageing-content-h">{P weidogsadmin}</ul>
     	</div>
	</div>
	<script src="/cdn/jquery.min.js"></script>
	<script src="/layui/layui.all.js"></script>
	<script src="/js/ajax.js"></script>
	<script type="text/javascript">
		var form = layui.form;
		function check(){
			layer.tips('<a>可从【自动拉群】选择门店对应的拉群活码使用</a>', '#sones', {
			  	tips: [1, 'white'],
				area: ['300px', 'auto'],
		    	time: 50000
			});
		}

		function checks(){
			layer.tips('<a>开启后，距离较近的客户扫码即可入群，关闭后客户扫码将无法就近入群</a>', '#sone', {
				tips: [1, 'white'],
				area: ['300px', 'auto'],
		    	time: 50000
			});
		}

		function mous(){
			layer.closeAll();
		}
		//搜索
		function search(){
			var city = $("#city").val();
			var name = $("#name").val();
			var status = $("#status").val();
			if(name == "{$name}"){
				return false;
			}
			window.location.href = window.location.pathname+"?city="+city+"&name="+name+"&status="+status;
		}
		//搜索
		form.on("select(lay-search)", function(data){
			var city = $("#city").val();
			var name = $("#name").val();
			var status = $("#status").val();
			if(status == "{$status}" && city == "{$city_one}"){
				return false;
			}
			window.location.href = window.location.pathname+"?city="+city+"&name="+name+"&status="+status;
		})

		//修改活码
		form.on("select(upd_way)", function(data){
	    	var id = data.elem.attributes[3].nodeValue;
	    	var contact_id = data.value;
	    	myAjaxPost(false, true, 'upd_way.html', { id:id,contact_id:contact_id}, function (resp) {
	    		layer.msg(resp.msg);
	    		if(resp.status != "success"){
	    			setTimeout(function(){
	                  	window.location.reload();
	                },1500);
	    		}
	    	})
		})
		//开启关闭
	    layui.form.on('switch(switchTest)', function (obj) {
	    	var id = obj.value;
	    	if(obj.elem.checked){
		        myAjaxPost(false, true, 'add_status.html', { id:id}, function (resp) {
	    			layer.msg(resp.msg);
	    			if(resp.status != "success"){
	    				setTimeout(function(){
		                  	window.location.reload();
		                },1500);
	    			}
	    		})
	    	}else{
	    		myAjaxPost(false, true, 'del_status.html', { id:id}, function (resp) {
	    			layer.msg(resp.msg);
	    			if(resp.status != "success"){
	    				setTimeout(function(){
		                  	window.location.reload();
		                },1500);
	    			}
	    		})
	    	}
	    })
	    //删除
	    function del_city(id){
	    	myAjaxPost(false, true, 'del_stores.html', { id:id}, function (resp) {
    			layer.msg(resp.msg);
    			if(resp.status == "success"){
    				setTimeout(function(){
	                  	window.location.reload();
	                },1500);
    			}
    		})
	    }
	    //重置
		function reset(){
			window.location.href = window.location.pathname;
		}
	</script>
	<script type="text/javascript">
		layui.use('form', function(){
			var form = layui.form;

		  //监听提交
		  form.on('submit(formDemo)', function(data){
		  	layer.msg(JSON.stringify(data.field));
		  	return false;
		  });
		  
		});
		layui.use('laydate', function(){
		  var laydate = layui.laydate;
		  //日期时间范围
		  laydate.render({ 
		    elem: '#test10'
		    ,range: true //或 range: '~' 来自定义分割字符
		  });
		  
		});
		layui.use('table', function(){
		  var table = layui.table;
		  //转换静态表格
		  table.init('clientTable', {
		    page: !{limit: 1},
		    // 页码变化会触发
		    done: function(res, curr, count) {
		      currTablePage = curr
		    }
		  })
		  table.on('checkbox(clientTable)', function(obj){
		    var result = getPageSelected();
		    tableSelected[currTablePage] = result
		  })
		})
	</script>
	<!-- 切换tabs -->
	<script type="text/javascript">
		$(".StoreCode_mainNav_container li").click(function(){
			$(".StoreCode_mainNav_container li").removeClass('StoreCode_mainNavActive');
			$(this).addClass('StoreCode_mainNavActive');
			let type = $(this).attr('data-type');
			if (type == "store") {
				$('.StoreCode_TabsDataAnalysis_container').hide();
				$('.StoreCode_TabsStoreList_container').show();
			}else if(type == "data"){
				$('.StoreCode_TabsStoreList_container').hide();
				$('.StoreCode_TabsDataAnalysis_container').show();
			}
		})
		// 数据分析页第二个tabs
		$('.StoreCode_TabsDataAnalysis_secendTabs_container li').click(function(){
			$('.StoreCode_TabsDataAnalysis_secendTabs_container li').removeClass('StoreCode_TabsDataAnalysis_secendTabs_active');
			$(this).addClass('StoreCode_TabsDataAnalysis_secendTabs_active');
			let type = $(this).attr('data-type');
			if (type == "store") {
				$('.StoreCode_TabsDataAnalysis_Main_container').hide();
				$('.StoreCode_TabsDataStore_Main_container').show();
			}else if(type == "customer"){
				$('.StoreCode_TabsDataStore_Main_container').hide();
				$('.StoreCode_TabsDataAnalysis_Main_container').show();
			}
		})
		// 点击显示添加门店隐藏区域
		$('#Add-Store').click(function(){
			$('.StoreCode_AddStroeHide_container').toggle();
		})
		//修改
		function add_city(id){
			layer.open({
			  type: 2,
			  title: '添加城市',
			  shadeClose: true,
			  shade: 0.2,
			  area: ['495px', '568px'],
			  content: 'add_city.html?id='+id
			}); 
		}
		// 弹窗
		$('.addstore').on('click',function(){
			layer.open({
			  type: 2,
			  title: '添加城市',
			  shadeClose: true,
			  shade: 0.2,
			  area: ['495px', '568px'],
			  content: 'add_city.html'
			}); 
		})
		$('#share').on('click',function(){
			layer.open({
			  type: 2,
			  title: '分享',
			  shadeClose: true,
			  shade: 0.2,
			  area: ['575px', '450px'],
			  content: 'share.html'
			}); 
		})
		$('#importstore').on('click',function(){
			layer.open({
			  type: 2,
			  title: '导入城市',
			  shadeClose: true,
			  shade: 0.2,
			  area: ['845px', '763px'],
			  content: 'add_all.html'
			}); 
		})
		$('#setting').on('click',function(){
			layer.open({
			  type: 2,
			  title: '设置',
			  shadeClose: true,
			  shade: 0.2,
			  area: ['845px', '763px'],
			  content: 'setting.html'
			}); 
		})
	</script>
</body>
</html>